const go=(url)=>{
	const witeArray = ['/pages/login/login','/pages/register/register']
	let token = uni.getSystemInfoSync('token')
	if(!token){
		return uni.navigateTo({
			url:'/pages/login/login'
		})
	}
	const app = require('@/pages.json')
	const tabbarLits = app.default.tabBar.list
	const tabbarArray = tabbarLits.map(item=>'/'+item.pagePath)
	console.log('333',tabbarArray);
	if(tabbarArray.includes(url)){
		uni.switchTab({
			url
		})
	}else{
		uni.navigateTo({
			url
		})
	}

}
// 判断图片类型
const chooseImageType= (temFiles)=>{
		if(!temFiles) return false
	const imageType = ['image/jpeg','image/jpg','image/png','image/gif']
	return temFiles.every(item=>imageType.includes(item.type))
}
// 判断图片大小
const chooseImageSize= (temFiles)=>{
		if(!temFiles) return false

	return temFiles.every(item=>(item.size/1024/1024)<2)
}
const opload=(tempFilePaths)=>{
			return new Promise((reslove,rejuct)=>{
				
				uni.uploadFile({
					url: 'http://api.quanjiu.net/estate/api/upload/add', //仅为示例，非真实的接口地址
					filePath: tempFilePaths,
					name: 'file',
					header:{
						Authorization: uni.getStorageSync('token') //自定义请求头信息	
					},
					formData: {
						'user': 'test'
					},
					success: (uploadFileRes) => {
						// console.log('11111',uploadFileRes.data);
						let data = JSON.parse(uploadFileRes.data)
						if(data.errCode ==10200){
							uni.navigateTo({
								url:"/pages/login/login"
							})
						}
						// console.log(data,'1234');
						reslove(data.data)
					}
				});
			})
			}
			
export default{
	go,
	opload,
	chooseImageType,
	chooseImageSize
	
}